import axios from "axios";
import { GET_TOKEN } from "@/util/storage";

const request = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000
});

request.interceptors.request.use(
  config => {
    config.headers["Authorization"] = GET_TOKEN();
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);
request.interceptors.response.use(
  response => {
    return response.data;
  },
  error => {
    // Do something with response error
    return Promise.reject(error);
  }
);

export default request;
